import request from '@/utils/request'

// 注册算法sku
export function arithmeticRegisterV2(params) {  //等会test
  console.log('#####新增');
  
  const { url = '', file } = params
  return request({
    url: `/arithmetic/sku/register-v2?${url.slice(1)}`,
    //url: `/genius/platform-arithmetic-v4/register-v2?${url.slice(1)}`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    method: 'POST',
    data: file,
    timeout: 60 * 3 * 1000,
  })
}

//图片识别
export function algV4Detect(params) {
  const { url = '', file } = params
  return request({
    url: `/genius/platform-arithmetic-v4/detect?${url.slice(1)}`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    method: 'POST',
    data: file,
    timeout: 60 * 3 * 1000,
  })
}

// 根据id获取某个算法的详情
export function getArithmeticDetail(query) {
  return request({
    url: '/genius/platform-arithmetic-v4/get-by-id',
    method: 'get',
    params: query
  })
}

// 修改指定SKU，指定层的小图
export function modifySkuMinImgList(params) {
  const { skuId = '', files } = params
  return request({
    url: `/arithmetic/sku/modify?skuId=${skuId}`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    method: 'POST',
    data: files,
    timeout: 60 * 3 * 1000
  })
}

// 修改指定SKU，指定层的小图
export function addSkuMinImgList(params) {
  const { skuId = '', files } = params
  return request({
    url: `/arithmetic/sku/addSkuImage?skuId=${skuId}`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    method: 'POST',
    data: files,
    timeout: 60 * 3 * 1000
  })
}



// 获取V4算法列表
export function getAlgListV4(params) {
  return request({
    //url: '/arithmetic/algsku/v4/list-page',
    url:'/genius/platform-arithmetic-v4/list',
    method: 'GET',
    params
  })
}

// 分解图片
export function uploadFile(data) {
  return request({
    url: `/arithmetic/cut-controller/cut-image`,
    method: "post",
    data,
    timeout: 60 * 20 * 1000
  })
}

// 批量分解主图，得到小图文件夹
export function batchCutMinImgFilePackage(data) {
  // const{files} =params
  // console.log(files)
  return request({
    responseType: 'blob',
    url: `/arithmetic/cut-controller/cut-image`,
    method: 'post',
    data,
    timeout: 60 * 20 * 1000
  })
}

// 重启v4服务
export function v4Restart(params) {
  return request({
    //url: '/algsku/v4/restart',
    url:'/genius/platform-arithmetic-v4/restart',
    method: 'post',
    data:params
  })
}

// 查看v4重启结果
export function getV4RestartResult() {
  return request({
    //url: 'algsku/v4/getRestartResult',
    url:'/genius/platform-arithmetic-v4/get-restart-result',
    method: 'GET'
  })
}

//查看当前算法阈值V4
export function getThresholdValueV4() {
  return request({
    //url: '/arithmetic/algsku/v4/getThreshold',
    url:'/genius/platform-arithmetic-v4/get-threshold',
    method: 'GET'
  })
}

//  V4算法-删除
export function delAlgoV4(params) {
  return request({
    //url: '/algsku/v4/delete',
    url:'/genius/platform-arithmetic-v4/delete',
    method: 'DELETE',
    params
  })
}

//V4算法绑定
export function algBindV4(params) {
  return request({
    url: '/genius/platform-goods/bindV4', 
    method: 'post',
    data: params,
  })
}

//V4算法解绑
export function algUnBindV4(params) {
  return request({
    url: '/genius/platform-goods/unBindV4',
    method: 'post',
    data: params,
  })
}

//V4算法-注册算法SKU（注册成功返回算法skuId）
export function algRegisterV4(params) {
  const { url = '', file } = params
  return request({
    //url: `/arithmetic/algsku/v4/register?${url.slice(1)}`,
    url:`/genius/platform-arithmetic-v4/register-v2?${url.slice(1)}`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    method: 'post',
    data: file,
    timeout: 60 * 3 * 1000,
  })
}

//V4算法-修改算法SKU（修改指定算法sku的主图或者小图组）
export function algModifyV4(params) {
  const { url = '', file } = params
  return request({
    //url: `/algsku/v4/modify?${url.slice(1)}`,
    url: `/genius/platform-arithmetic-v4/modify?${url.slice(1)}`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    method: 'post',
    data: file,
    timeout: 60 * 3 * 1000,
  })
}


//设置阈值V4
export function setThresholdValueV4(params) {
  return request({
    url:'/genius/platform-arithmetic-v4/setThreshold',
    method: 'post',
    data: params,
  })
}

// 查看商户所有SKU，分页
export function getGoodsList(params) {
  return request({
    //url: '/sku/list-page',
    url:'/genius/platform-goods/list',
    method: 'GET',
    params: params,
  })
}

// 查询冰柜类型列表
export function listContainerType(query) {
  return request({
    url: '/genius/platform-container-type/list',
    method: 'get',
    params: query
  })
}

// 查询冰柜类型详情
export function getContainerTypeDetail(id) {
  return request({
    url: '/genius/platform-container-type/' + id,
    method: 'get'
  })
}

// 新增冰柜类型
export function addContainerType(data) {
  return request({
    url: '/genius/platform-container-type',
    method: 'post',
    data: data
  })
}

// 修改冰柜类型
export function updateContainerType(data) {
  return request({
    url: '/genius/platform-container-type',
    method: 'put',
    data: data
  })
}
// 导出冰柜类型
export function exportContainerType(data) {
  return request({
    url: '/genius/platform-container-type/export',
    method: 'post',
    data: data
  })
}

// 逻辑删除冰柜类型信息
export function delContainerType(ids) {
  return request({
    url: '/genius/platform-container-type/' + ids   ,
    method: 'delete'
  })
}

// 遮挡识别
export function shelterRecognize(params) {
  const { projectId = '', images, threshold='', imageUrl= '' } = params
  return request({
    url: `/genius/platform-cover-algo/get-cover?projectId=${projectId}&&threshold=${threshold}&&imageUrl=${imageUrl}`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    method: 'POST',
    data: images,
    timeout: 60 * 3 * 1000
  })
}

//设置遮挡阈值V4
export function setShelterThresholdV4(params) {
  return request({
    url:'/genius/platform-cover-algo/edit-threshold',
    method: 'put',
    data: params,
  })
}
